#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N =110;
double a[N];
ll n;
int main()
{
    cin >> n;
    for (ll i = 1; i <= n;i++)
    {
        cin >> a[i];
    }
    map<ll, ll> mp;
    double ans = 0.0;
    ll q, w;
    while(cin >> q >> w)
    {
        if(q==0)
            break;
        mp[q] += w;
        ans += a[q] * w;
    }
    for (ll i = 1; i <= n;i++)
    {
        cout << mp[i] << endl;
    }
    printf("%.2lf", ans);
}